package com.likersai.opon.service.param.menu;

import com.likersai.opon.pojo.dto.param.menu.MenuSelect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 菜单查询入参
 *
 * @author sun.ye
 * @since 2021-03-14 00:35
 */
@Data
@ApiModel(value="菜单查询入参",description="菜单查询入参" )
public class MenuQuery {

    @ApiModelProperty(value = "唯一主键",example = "1")
    private Long id;

    @ApiModelProperty(value = "菜单名称",example = "首页")
    private String menuName;

    @ApiModelProperty(value = "菜单编码",example = "opon_home")
    private String menuCode;

    @ApiModelProperty(value = "父菜单ID",example = "0")
    private Long parentId;

    @ApiModelProperty(value = "展示类型",example = "DYN")
    private String type;

    @ApiModelProperty(value = "分页页码",example = "1")
    private Integer pageNum;

    @ApiModelProperty(value = "分页页长",example = "10")
    private Integer pageSize;


    public MenuSelect toMenuQuery(){
        MenuSelect menuSelect = new MenuSelect();
        menuSelect.setId(id);
        menuSelect.setMenuName(menuName);
        menuSelect.setMenuCode(menuCode);
        menuSelect.setParentId(parentId);
        menuSelect.setType(type);
        if(pageNum != null && pageSize != null){
            menuSelect.setPage(true);
            menuSelect.setRowStart((pageNum - 1) * pageSize);
            menuSelect.setPageSize(pageSize);
        }else {
            menuSelect.setPage(false);
        }
        return menuSelect;
    }
}


